﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master"
  AutoEventWireup="true" CodeBehind="SettingPage.aspx.cs" Inherits="NguyenHoa.Web.Admin.SettingPage" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div class="insert_header">
    <asp:Label ID="Label6" runat="server" Text="<%$Resources:Strings, MailConfigure %>"></asp:Label>
  </div>
  <table style="padding: 10px 0px 0px 40px" class="CommonFont">
    <tr>
      <td width="170px;">
        <asp:Label ID="Label1" runat="server" Text="<%$Resources:Strings, SMTPHost %>"></asp:Label>
        :
      </td>
      <td style="width: 20px;">
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtHost" ClientInstanceName="txtHost" runat="server" Width="200px"
          ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label2" runat="server" Text="<%$Resources:Strings, SMTPPort %>"></asp:Label>
        :
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtPort" ClientInstanceName="txtPort" runat="server" Width="80px"
          ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
          <MaskSettings IncludeLiterals="None" />
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label4" runat="server" Text="<%$Resources:Strings, SMTPUser %>"></asp:Label>
        :
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtUser" ClientInstanceName="txtUser" runat="server" Width="200px"
          ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label5" runat="server" Text="<%$Resources:Strings, SMTPPass %>"></asp:Label>
        :
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtPass" ClientInstanceName="txtPass" runat="server" Width="200px"
          ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr style="display: none;">
      <td>
        <asp:Label ID="Label3" runat="server" Text="<%$Resources:Strings, ReceivedContactEmail %>"></asp:Label>
        :
      </td>
      <td>
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtContactEmail" ClientInstanceName="txtContactEmail" runat="server"
          Width="200px" ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label17" runat="server" Text="<%$Resources:Strings, NotifyBookingEmail %>"></asp:Label>
        :
      </td>
      <td>
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtNotifyBookingEmail" ClientInstanceName="txtNotifyBookingEmail"
          runat="server" Width="200px" ClientEnabled="False">
          <ValidationSettings>
            <ErrorImage Height="14px" />
          </ValidationSettings>
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
      </td>
      <td>
      </td>
      <td style="padding: 3px 0px 0px 0px;">
        <dxe:ASPxCheckBox ID="ckbSSL" ClientInstanceName="ckbSSL" runat="server" ClientEnabled="False"
          Text="<%$ Resources:Strings, EnableSSL %>">
        </dxe:ASPxCheckBox>
      </td>
    </tr>
    <tr>
      <td>
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <div style="float: left; padding-top: 10px;">
          <dxe:ASPxButton ID="btnEdit" ClientInstanceName="btnEdit" runat="server" 
            Text="<%$ Resources:Strings, Edit %>">
            <ClientSideEvents Click="function(s,e){onEdit('MAIL');e.processOnServer=false;}" />
          </dxe:ASPxButton>
        </div>
        <div style="float: left; padding-left: 3px; padding-top: 10px;">
          <dxe:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" 
            Text="<%$ Resources:Strings, Save %>" ClientEnabled="False"
            AutoPostBack="False">
            <ClientSideEvents Click="function(s,e){onSave('MAIL');e.processOnServer=false;}" />
          </dxe:ASPxButton>
        </div>
      </td>
    </tr>
  </table>
  <div class="insert_header" style="padding-top: 30px;">
    <asp:Label ID="Label8" runat="server" Text="<%$Resources:Strings, ReferenceLink %>"></asp:Label>
  </div>
  <table style="padding: 10px 0px 0px 40px" class="CommonFont">
    <tr>
      <td width="170px;">
        <asp:Label ID="Label9" runat="server" Text="<%$Resources:Strings, RateExchange %>"></asp:Label>
        :
      </td>
      <td style="width: 20px;">
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtRateEx" ClientInstanceName="txtRateEx" runat="server" Width="400px"
          ClientEnabled="False">
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label10" runat="server" Text="<%$Resources:Strings, GoldRate %>"></asp:Label>
        :
      </td>
      <td>
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtGold" ClientInstanceName="txtGold" runat="server" Width="400px"
          ClientEnabled="False">
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label11" runat="server" Text="<%$Resources:Strings, StockOnline %>"></asp:Label>
        :
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtStock" ClientInstanceName="txtStock" runat="server" Width="400px"
          ClientEnabled="False">
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label12" runat="server" Text="<%$Resources:Strings, TVOnline %>"></asp:Label>
        :
      </td>
      <td>
        &nbsp;
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtTV" ClientInstanceName="txtTV" runat="server" Width="400px"
          ClientEnabled="False">
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
        <asp:Label ID="Label13" runat="server" Text="<%$Resources:Strings, Loto %>"></asp:Label>
        :
      </td>
      <td>
      </td>
      <td>
        <dxe:ASPxTextBox ID="txtLoto" ClientInstanceName="txtLoto" runat="server" Width="400px"
          ClientEnabled="False">
        </dxe:ASPxTextBox>
      </td>
    </tr>
    <tr>
      <td>
      </td>
      <td>
      </td>
      <td style="padding-top: 10px;">
        <div style="float: left;">
          <dxe:ASPxButton ID="btnEditLink" ClientInstanceName="btnEditLink" runat="server"
            Text="<%$ Resources:Strings, Edit %>">
            <ClientSideEvents Click="function(s,e){onEdit('LINK');e.processOnServer=false;}" />
          </dxe:ASPxButton>
        </div>
        <div style="float: left; padding-left: 3px;">
          <dxe:ASPxButton ID="btnSaveLink" ClientInstanceName="btnSaveLink" runat="server"
            Text="<%$ Resources:Strings, Save %>" ClientEnabled="False">
            <ClientSideEvents Click="function(s,e){onSave('LINK');e.processOnServer=false;}" />
          </dxe:ASPxButton>
        </div>
      </td>
    </tr>
  </table>
  <div>
    <dxcb:ASPxCallback ID="ctrlCallback" ClientInstanceName="ctrlCallback" runat="server"
      OnCallback="ctrlCallback_Callback">
      <ClientSideEvents CallbackComplete="function(s,e){onctrlCallback_CallbackComplete(s,e);}" />
    </dxcb:ASPxCallback>
  </div>

  <script type="text/javascript" language="javascript">
    function onctrlCallback_CallbackComplete(s, e) {
      pcWaiting.Hide();
      var error = e.result;
      if (error != '') {
        if (error.indexOf('OK') >= 0) {
          var para = error.split('|');
          enableControl(para[1], false);
          alertSuccess();
        }
        else
          alertMessage(error);
      }
    }

    function onEdit(type) {
      enableControl(type, true);
    }

    function onSave(type) {
      if (type == 'MAIL') {
        var error = '';
        if (txtUser.GetText() != '' && !ValidateEmail(txtUser.GetText())) {
          error = '<%=(string)GetGlobalResourceObject("Strings", "SMTPUser") %>';
        }
        else if (txtContactEmail.GetText() != '' && !ValidateEmail(txtContactEmail.GetText())) {
          error = '<%=(string)GetGlobalResourceObject("Strings", "ReceivedContactEmail") %>';
        }
        else if (txtNotifyBookingEmail.GetText() != '' && !ValidateEmail(txtNotifyBookingEmail.GetText())) {
          error = '<%=(string)GetGlobalResourceObject("Strings", "NotifyBookingEmail") %>';
        }
        if (error != '') {
          error += ': ' + '<%=(string)GetGlobalResourceObject("Messages", "ERR0029") %>';
          alertMessage(error);
          return;
        }
      }
      pcWaiting.Show();
      ctrlCallback.SendCallback('Save|' + type);
    }

    function enableControl(type, enable) {
      if (type == 'MAIL') {
        btnSave.SetEnabled(enable);
        btnEdit.SetEnabled(!enable);
        txtHost.SetEnabled(enable);
        txtPort.SetEnabled(enable);
        ckbSSL.SetEnabled(enable);
        txtUser.SetEnabled(enable);
        txtPass.SetEnabled(enable);
        txtContactEmail.SetEnabled(enable);
        txtNotifyBookingEmail.SetEnabled(enable);
      }
      else if (type == 'LINK') {
        btnEditLink.SetEnabled(!enable);
        btnSaveLink.SetEnabled(enable);
        txtRateEx.SetEnabled(enable);
        txtGold.SetEnabled(enable);
        txtStock.SetEnabled(enable);
        txtTV.SetEnabled(enable);
        txtLoto.SetEnabled(enable);
      }
    }
 
  </script>

</asp:Content>
